问题列表 - 第19079页

C中的螺纹安全性

想象一下我用C编写了一个库.进一步,想象一下这个库是从多线程环境中使用的.如何使其线程安全?更具体:我如何确保某些功能一次只能由一个线程执行?

例如,与Java或C#相反,C无法处理线程/锁/等,C标准库也没有.我知道,操作系统支持线程,但使用他们的api会极大地限制我的库的兼容性.我有哪些可能性,以保持我的库兼容/便携?(例如,依赖于OpenMP,或者在Posix线程上,使其至少与所有类似Unix的操作系统兼容?)

c multithreading thread-safety

10
推荐指数
2
解决办法
1万
查看次数

有多少MySQL行太多了?

我正在开发一个网站,该网站主要使用一个包含组织表的数据库,每个组织一行.每个组织都可以拥有无​​限数量的附加关键字.关键字在与组织分开的表中表示,其中每一行只是主键,关键字和附加到的组织的主键.最终这个表可能有数千个条目.这会从此表中提取记录,以及在表格中列出唯一关键字,是否太费时间?

mysql

18
推荐指数
1
解决办法
1万
查看次数

jQuery Datepicker - 禁用周末/假期以及接下来的三个工作日

使用这种相当简洁的方法,我可以从datepicker禁用周末和假期.

但是,我希望将此与从今天开始的下三个工作日的禁用相结合.只需设置最短日期相对简单:

var dateMin = new Date();
dateMin.setDate(dateMin.getDate() + 3);
$(function() {

 $('#txtCollectionDate').datepicker(
 {
  beforeShowDay: noWeekendsOrHolidays,
  showOn: "both",
  dateFormat: "dd/mm/yy",
  firstDay: 1,
  changeFirstDay: false,
  minDate: dateMin
 });

});
Run Code Online (Sandbox Code Playgroud)

但是,我真正需要一个计算工作日的函数:

var dateMin = new Date();
dateMin.setDate(AddBusinessDays(3));
Run Code Online (Sandbox Code Playgroud)

任何人都能够转换为JavaScript?

jquery datepicker

3
推荐指数
1
解决办法
4万
查看次数

Delphi Prism是Delphi .net的新版本吗?

首先(在这个问题投票之前):我是一名开发人员,使用面向Win32的Delphi开发99,99%的程序(在Delphi 7中开发仍然非常缓慢地迁移到Delphi 2010).

当Delphi 2006或2007(不记得目前是哪个版本)问世时,我购买了RAD Studio版本,以便能够使用Delphi.net和VCL.net开始开发.net应用程序.

我玩了很短的时间,但最后,由于工作量刚刚使用Delphi 7作为开发平台.

当Delphi 2010发布时,我决定再次给.net一次,并且(愚蠢地)再次购买了Studio许可证,认为包含PRISM是以前的Delphi.net(将在Delphi IDE中开发).

现在我已经安装了PRISM(以及Visual Studio 8 IDE - 恐怖),我只是想知道PRISM是否是Delphi.Net的新版本(可能不是).如果我可以在Prism下使用我的一些Win32代码.

一些回复后的更新:我保持​​问题开放,因为当答案尚未被选中时,你会得到更多答案.

我确实想念Delphi IDE.它既有品味又需要开发两种不同的IDE(键盘快捷键不同 - 我不想放弃Delphi,谢谢))这不是我花费我开发时间的想法.

delphi oxygene delphi-prism delphi-2010

5
推荐指数
4
解决办法
1514
查看次数

调试操作系统

我正在阅读有关操作系统的一些常规内容并触及一个问题.开发人员在开发操作系统时如何调试,即调试操作系统本身?可以为OS开发人员调试哪些工具?

debugging operating-system kernel

24
推荐指数
1
解决办法
7242
查看次数

如何拦截Linux桌面上的HTTP请求?

如果有人能给我一个如何实现这个的想法,我真的很感激.此外,是否可以为大多数流行的Linux桌面发行版(如果不是全部)提供通用实现.谢谢.

我需要实现的是像Windows服务,每次操作系统启动时都会自动运行.它的作用是拦截从浏览器发出的所有HTTP请求并记录请求URL.希望现在很清楚.

linux linux-kernel

1
推荐指数
1
解决办法
4419
查看次数

为什么我可以在C#中编写一个通用的catch语句,什么都不做?

可能重复:
为什么我不能在C#中捕获一般异常?

我最近一直在审查和编写Circuit Breaker代码.编译以下方法,但永远不会输入catch块.我有很多解决方法,这不是获得正确行为(过滤异常)的唯一方法,但我很好奇为什么这个编译并且不起作用!

public void AttemptCall<TException>(Action action) 
    where TException : Exception
{
    try
    {
        action();
    }
    catch(TException e)  // This block is never entered!
    {
         state.ActUponException(e);
         throw;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是一个应该进入前一个方法的catch块的测试.

[TestMethod]
public void Throw_an_exception()
{
    circuitBreaker.AttemptCall<Exception>(() => throw new Exception());
    // test the circuit breaker's state
}
Run Code Online (Sandbox Code Playgroud)

c# generics try-catch circuit-breaker

10
推荐指数
1
解决办法
1236
查看次数

如何在C++中初始化动态数组?

如何实现此静态数组初始化的动态等价物:

char c[2] = {};  // Sets all members to '\0';
Run Code Online (Sandbox Code Playgroud)

换句话说,创建一个动态数组,其中所有值都初始化为终止字符:

char* c = new char[length]; // how do i amend this? 
Run Code Online (Sandbox Code Playgroud)

c++ arrays

56
推荐指数
6
解决办法
10万
查看次数

设计视角:静态方法与类

虽然这是一个相当普遍的问题,但我正在努力解决它的最佳方法(如果在这种情况下需要接近它).

I have inherited a website (ASP.NET, C#) part of which contains a class full of static methods (it's a very large class, honestly). One method in particular is for sending e-mails. It has every possible parameter I can think of and it works well enough. However, the internals of that particular method are rather cumbersome to manage and understand due to the fact that everything is shoved inside - particularly when most of the parameters aren't used. In addition, …

c# asp.net static-methods

1
推荐指数
1
解决办法
755
查看次数

jquery firefox stopPropagation()

I'm binding two event handlers to an input field on 'keydown'. If the enter key has been pressed, the first event handler needs to stop the propagation of the event so that it doesn't hit the second eventhandler. I'm doing it like so:

if (jQuery.browser.msie) {
                    event.cancelBubble = true;
                } else {
                    event.stopPropagation();
                }
Run Code Online (Sandbox Code Playgroud)

now this alone doesn't stop the event propagation either in IE or Firefox. It hits the first event handler, and then hits the second event handler …

firefox jquery event-handling

5
推荐指数
1
解决办法
7251
查看次数